/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Utils;
/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */

import java.sql.ResultSet;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRResultSetDataSource;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;

public class Grafico {
    
    public void grafico(String caminho,ResultSet rs){
        JRResultSetDataSource jrRS = new JRResultSetDataSource(rs);
        try {
            JasperPrint jasperPrint = JasperFillManager.fillReport(caminho, new HashMap(),jrRS);
            
            JasperViewer view = new JasperViewer(jasperPrint,false);
            view.setTitle("grafico");
            view.setExtendedState(JasperViewer.MAXIMIZED_BOTH);
            view.setVisible(true);
        } catch (JRException ex) {
            Logger.getLogger(Grafico.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}




  